package org.smile.playground;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class ZThread {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        System.out.println("main is working");

        //第一种继承方式
        TThread tThread1 = new TThread();
        tThread1.start();
        tThread1.sleep(1000);


        TThread tThread2 = new TThread();
        tThread2.start();

        TThread tThread3 = new TThread();
        tThread3.start();

        TThread tThread4 = new TThread();
        tThread4.start();

        TThread tThread5 = new TThread();
        tThread5.start();

        TThread tThread6 = new TThread();
        tThread6.start();

        TThread tThread7 = new TThread();
        tThread7.start();
        //第二中接口方式
        new Thread(new Trun()).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("inner is working");
            }
        }).start();

        new Thread(() -> {
            System.out.println("lamada is working");
        }).start();

        System.out.println("exit");


        FutureTask<Integer> futureTask = new FutureTask<>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                return 1;
            }
        });

//        futureTask.run();
        new Thread(futureTask).start();
        Integer a = futureTask.get();
        System.out.println(a);


    }

}
